package com.example.mideaoem.data.humidification;

import com.example.mideaoem.data.BaseDevice;
import com.example.mideaoem.data.FactoryDataBody;
import com.example.mideaoem.data.fcCon;

public class DataBodyHumiRequest extends FactoryDataBody{

	// 控制类型
		public byte controlType = 0x40;

		public int humidity_dot;//湿度小数位
		public int humidity;//湿度整数位
		
		public int humidity_set;
		public int humidity_dot_set;
		
		public int windSpeed;
		public boolean isDisplay;
		public int timingFuncOn;
		
		public byte powerMode;
		
		// 设定模式
		public byte setMode;

		// 定时开机时间，分
		public byte timingOpenMinute;
		// 定时开－绝对小时
		public byte timingOpenHour;
		// 定时开,0- 关,1- 开
		public byte timingOpenMark;

		// 定时关－绝对分
		public byte timingCloseMinute;
		// 定时关－绝对小时
		public byte timingCloseHour;
		// 定时关,0- 关,1- 开
		public byte timingCloseMark;
		
		private byte[] testData;
	
	@Override
	public byte[] toBytes() {
		// TODO Auto-generated method stub
		
		fcCon con = new fcCon();
		int[] src = new int[128];
		int[] des = new int[10];
		con.btnSound = 1;
		con.controlSource = 1;
		con.optCommand = 3;
		mOrder ++;
		con.order = mOrder;//要每次不一样
		
		//转换
		con.runStatus = powerMode;
		con.windSpeed = windSpeed;
		con.humidity = humidity_set;
		con.humidity_set_dot = humidity_dot;
		con.mode_FD_return = setMode;
		
		con.displayClass = isDisplay?0:7;
		
		int length = con.stdAirConEx_pro2byte(161, fcCon.CMDTYPE_SET, src, src.length, des, des.length);
		byte[] result = toBytes(src, length);
		testData = result.clone();
		result = addHead(result, fcCon.HUMI);
		printHexString(result);
		
		return result;
	}

	public byte[] getTestData(){
		if(testData != null){
			return testData;
		}else{
			return new byte[]{};
		}
	}
	
	@Override
	public Object toObject(byte[] bytes) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void setDataBodyStatus(BaseDevice request) {
		// TODO Auto-generated method stub
		if(request instanceof Humidification){
			this.powerMode = ((Humidification) request).powerMode;
			this.windSpeed = ((Humidification) request).windSpeed;
			this.humidity_set = ((Humidification) request).humidity_set;
			this.humidity_dot_set = ((Humidification) request).humidity_dot_set;
			this.setMode = ((Humidification) request).setMode;
			this.isDisplay = ((Humidification) request).isDisplay;
		}
	}

}
